// /////////////////////////////////////////////////////////////////////////////
//
// Name:            EntityComponent.h
// Author:          Michael Bartsch (ZCCdark203)
//
// Desc :           Declaration of the EntityComponent class.
//
// License:         Copyright (C) 2009 Michael Bartsch and Contributors
//
//                  This program is free software: you can redistribute it
//                  and/or modify it under the terms of the zlib/libpng License.
//                  See main.cpp for conditions of distribution and use.
//
// /////////////////////////////////////////////////////////////////////////////

#ifndef __ENTITYCOMPONENT_H__
#define __ENTITYCOMPONENT_H__

// Include files
#include "../dependencies.h"
#include "Serializable.h"
#include "Entity.h"

// Forward declarations
class Entity;


// EntityComponent class
//! Abstraction base class for adding new functionalities to entities.
class EntityComponent : public HasSlots, public Serializable
{
    friend class ScriptedEntityComponent;

public:

    // Initialisation and deinitialisation
    //! Constructor
    //! @param parent        Pointer to parent Entity.
    EntityComponent(Entity *parent);
    //! Deconstructor
    virtual ~EntityComponent();

    // Methods
    //! Gets the ID of this component.
    u32 getID() const;

    //! Gets the name of this component.
    const std::string& getName() const;
    //! Gets the parent of this component.
    const Entity* getParent();

    // Serialization
    //! Serializes this object.
    //! @param attributes
    virtual bool onSerialization(SerializedAttributes *attributes);
    //! Deserializes this object.
    //! @param attributes
    virtual bool onDeserialization(SerializedAttributes *attributes);

protected:

    // Normal members
    Entity *pParent;

    u32 mID;
    std::string mName;

private:

    // Static members
    static u32 mIDCount;
};

#endif
